package poker;

import java.util.HashSet;

/**
 *
 * @author guglielmo90
 * @version 0.0.1
 */
public class Poker {

    /**
     * @param args the command line arguments
     */
   

    
    public static void main(String[] args) {
        
        double hand0score, hand1score;
        
        Table table = new Table();
        
        table.addPlayer("Verdi", 1500, 0, 0);
        table.addPlayer("Oppo", 1500, 1, 0);
        
        do {
            
            table.setHandDoneFalse();
            
            table.shuffleUpAndDeal();

            table.showTable();
            int bet = table.preflopAction(0, 0);
            System.out.println("\nOppo calls " + bet);
            table.getPlayers().get(1).lose(bet);
            table.potInc(bet);
            if(table.getHandDone() != true){
                
                table.getBoard().dealFlop();
                table.showTable();
                System.out.println("\nOppo bets 100");
                table.getPlayers().get(1).lose(100);
                table.potInc(100);
                bet = table.postflopAction(0,100);
                if(bet != -1){
                    
                    System.out.println("\nOppo calls " + bet);
                    table.getPlayers().get(1).lose(bet);
                    table.potInc(bet);
                    
                } 
            
            }
            
            if(table.getHandDone() != true){

                table.getBoard().dealTurn();
                table.showTable();
                System.out.println("\nOppo checks");
                bet = table.postflopAction(0, 0);
                if(bet != -1){
                    
                    System.out.println("\nOppo calls " + bet);
                    table.getPlayers().get(1).lose(bet);
                    table.potInc(bet);
                    
                } else if(bet == 0)
                    
                    System.out.println("\nOppo checks");
            
            }
            
            if(table.getHandDone() != true){
              
                table.getBoard().dealRiver();
                table.showTable();
                System.out.println("\nOppo checks");
                bet = table.postflopAction(0, 0);
                if(bet != -1){
                    
                    System.out.println("\nOppo calls " + bet);
                    table.getPlayers().get(1).lose(bet);
                    table.potInc(bet);
                    
                } else if(bet == 0)
                    
                    System.out.println("\nOppo checks");
                
                table.getBoard().setCards();
                hand0score = table.myHand(table.getPlayers().get(0).getHand());
                hand1score = table.myHand(table.getPlayers().get(1).getHand());
                System.out.println(hand0score);
                System.out.println(hand1score);
                
                if(hand0score > hand1score) {
                    
                    System.out.println(table.getPlayers().get(0).getNickname() + " won.");
                    table.handDone(0);
                }
                
                else {
                    System.out.println(table.getPlayers().get(1).getNickname() + " won.");
                    table.handDone(1);
                }
            
            }
            
            table.newHand();
            System.out.println("\n ---- NEW HAND  ----- \n");
            
        } while(table.getPlayers().get(0).getStack() != 0 ||  table.getPlayers().get(1).getStack() != 0 );
            
    }
    
}
